package com.wilmer.feedbackReply.service.impl;

import java.util.List;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import com.wilmer.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wilmer.feedbackReply.mapper.SysFeedbackReplyMapper;
import com.wilmer.feedbackReply.domain.SysFeedbackReply;
import com.wilmer.feedbackReply.service.ISysFeedbackReplyService;

/**
 * 问题反馈回复Service业务层处理
 * 
 * @author Jett
 * @date 2024-05-20
 */
@Service
public class SysFeedbackReplyServiceImpl implements ISysFeedbackReplyService 
{
    @Autowired
    private SysFeedbackReplyMapper sysFeedbackReplyMapper;

    @Autowired
    private ISysRoleService roleService;

    public static final Integer MANGE_ROlE_ID = 4;

    public static final Integer PARENT_ROlE_ID = 5;

    /**
     * 查询问题反馈回复
     * 
     * @param id 问题反馈回复主键
     * @return 问题反馈回复
     */
    @Override
    public SysFeedbackReply selectSysFeedbackReplyById(Long id)
    {
        return sysFeedbackReplyMapper.selectSysFeedbackReplyById(id);
    }

    /**
     * 查询问题反馈回复列表
     * 
     * @param sysFeedbackReply 问题反馈回复
     * @return 问题反馈回复
     */
    @Override
    public List<SysFeedbackReply> selectSysFeedbackReplyList(SysFeedbackReply sysFeedbackReply)
    {
        return sysFeedbackReplyMapper.selectSysFeedbackReplyList(sysFeedbackReply);
    }

    /**
     * 新增问题反馈回复
     * 
     * @param sysFeedbackReply 问题反馈回复
     * @return 结果
     */
    @Override
    public int insertSysFeedbackReply(SysFeedbackReply sysFeedbackReply)
    {
        sysFeedbackReply.setUserId(SecurityUtils.getUserId());
        sysFeedbackReply.setDeptId(SecurityUtils.getDeptId());
        //查看用户的角色信息
        Integer roleId = roleService.userRoleIdByUserId(SecurityUtils.getUserId());
        if(roleId == PARENT_ROlE_ID){
            sysFeedbackReply.setUserType(1L);
        } else if (roleId == MANGE_ROlE_ID) {
            sysFeedbackReply.setUserType(2L);
        }
        sysFeedbackReply.setCreateTime(DateUtils.getNowDate());
        return sysFeedbackReplyMapper.insertSysFeedbackReply(sysFeedbackReply);
    }

    /**
     * 修改问题反馈回复
     * 
     * @param sysFeedbackReply 问题反馈回复
     * @return 结果
     */
    @Override
    public int updateSysFeedbackReply(SysFeedbackReply sysFeedbackReply)
    {
        return sysFeedbackReplyMapper.updateSysFeedbackReply(sysFeedbackReply);
    }

    /**
     * 批量删除问题反馈回复
     * 
     * @param ids 需要删除的问题反馈回复主键
     * @return 结果
     */
    @Override
    public int deleteSysFeedbackReplyByIds(Long[] ids)
    {
        return sysFeedbackReplyMapper.deleteSysFeedbackReplyByIds(ids);
    }

    /**
     * 删除问题反馈回复信息
     * 
     * @param id 问题反馈回复主键
     * @return 结果
     */
    @Override
    public int deleteSysFeedbackReplyById(Long id)
    {
        return sysFeedbackReplyMapper.deleteSysFeedbackReplyById(id);
    }
}
